package com.ht.medicaltreatment.viewmodel

import androidx.lifecycle.viewModelScope
import com.ht.medicaltreatment.bean.LocationBean
import com.xgst.lib.http.ApiResult
import kotlinx.coroutines.launch

class LocationViewModel : BaseViewModel() {
    fun requestData(onResult:(MutableList<LocationBean>?)->Unit, onError:(String)->Unit){
        viewModelScope.launch {
            val bean = mApi.requestLocationData()
            when(bean){
                is ApiResult.Success -> onResult(bean.data.data)
                is ApiResult.Error -> onError(bean.errorMessage)
            }
        }
    }

}
